
#ifndef __display_h
#define __display_h

//HAL------------------------------
/* 数码管是共阴驱动，要置1才能亮
com口是低电平有效的，要置0才能驱动
LED是共阳的，要置0才能亮 */


#define F_setA()   P1_3 = 1 ;
#define F_setB()   P1_0 = 1 ;
#define F_setC()   P3_4 = 1 ;
#define F_setD()   P3_6 = 1 ;
#define F_setE()   P1_7 = 1 ;
#define F_setF()   P1_1 = 1 ;
#define F_setG()   P3_0 = 1 ;
#define F_setH()   P3_5 = 1 ;

#define F_clrA()  P1_3 = 0 ;
#define F_clrB()  P1_0 = 0 ;
#define F_clrC()  P3_4 = 0	;
#define F_clrD()  P3_6 = 0	;
#define F_clrE()  P1_7 = 0 ;
#define F_clrF()  P1_1 = 0 ;
#define F_clrG()  P3_0 = 0	;
#define F_clrH()   P3_5 = 0 ;


#define  F_displayMode() P1MODL &=b0000_0000;P1MODH &=b0000_1111; P3MODL &=b1111_0000; P3MODH &=b1100_0000;PINMOD &=b1111_0011;\
P1MODL |=b1010_1010;P1MODH |=b1010_0000; P3MODL |=b0000_1010; P3MODH |=b0010_1010;PINMOD |=b0000_1000;


#define  F_lockSegs() F_clrA();\
                      F_clrB();\
                      F_clrC();\
                      F_clrD();\
                      F_clrE();\
                      F_clrF();\
                      F_clrG();\
					  F_clrH();
 
#define  F_lockComs()		F_setCom1();\
                            F_setCom2();\
					        F_setCom3();	\
							F_setCom4();




// 共阴极数码管点亮条件是 ： 位控制端（公共端）需低电平，段控制端需要高电平
//#define F_setCom0()  P3_4 = 1  //Com0是指四个LED的公共端
#define F_clrCom2()   P2_1= 0;
#define F_clrCom1()	  P1_6= 0;
#define F_clrCom3()   P3_1 = 0;
#define F_clrCom4()   P1_2 = 0;


#define F_setCom2()    P2_1 = 1;
#define F_setCom1()    P1_6 = 1;
#define F_setCom3()    P3_1 = 1;
#define F_setCom4()   P1_2 = 1;


#define 	F_setSuReL1()    		displayBuffer[4]=0x40;
#define 	F_setYangShengChaL2()	displayBuffer[4]=0x04;
#define 	F_setTianPinL3()		displayBuffer[4]=0x08;
#define 	F_setZhuZhouL4()		displayBuffer[4]=0x10;
#define 	F_setDunTangL5()		displayBuffer[4]=0x02;
#define 	F_setMenZhuL5()			displayBuffer[4]=0x20;
#define 	F_setBaoWenL6()			displayBuffer[4]=0x01;

#define D_fontBar  0X40
#define D_fontBlank    0X00
#define D_fontE      0x4f
#define D_font0    0x3F
#define D_font1    0x30
#define D_font2	   0x5B
#define D_font3    	0x79
#define D_font8	0xff
//正c
//#define D_fontC 0x39
//倒小c带点
#define D_fontH 0x76;
#define D_fontC   0x8f;
//比com多1
#define D_DisplayBufferSize 5
// #define D_Coms 3
// #define D_LedCOM1 4
// #define D_LedCOM2 5
// #define D_LedCOM3 6
//Var------------------------------
#ifdef __dispaly_c
uint8_t displayBuffer[D_DisplayBufferSize] ;
#else
extern uint8_t displayBuffer[D_DisplayBufferSize] ;


#endif
//Function----------------------------
// void DisplayFunction(uint8_t number);
void DisplayScan(void) ;//
void DisplayNumber(uint16_t number) ;
// void DisplayCurTemp(uint16_t  number);
void DisplayTime(uint16_t number);
//void DisplayCurTemp(uint8_t  number);
// void DisplayTime1(uint8_t number);
// void DisplayTime2(uint8_t number);
// void SetComs(uint8_t dsp);
void ClrComs(uint8_t dsp);
// void DisplayNumber1(uint16_t number);


#define F_displayOFF()    displayBuffer[3] =0x3F ; \
                         displayBuffer[2] =      0x4e   ;displayBuffer[1] =      0x4e ;

#define F_displayClrAllLed()    displayBuffer[3] =   0x00 ;

#define F_displayBaoWen()       displayBuffer[3] =     0x00 ;         displayBuffer[2] =       0x4f ;displayBuffer[1] =       0x4f ;

#define F_displayGs()    displayBuffer[2] = D_fontE ;displayBuffer[1] = D_font3 ;

//#define 时，可以用 “\” 来把定义分成两行
#define F_displayAdShort()  displayBuffer[4] =     0x00 ;   displayBuffer[3] =     0x00 ;  displayBuffer[2] = D_fontE ;displayBuffer[1] =D_font2  ;

//当ad短路的时候，数码管显示  E0
#define F_displayAdOff()             displayBuffer[4] =     0x00 ; displayBuffer[3] =     0x00 ;  displayBuffer[2] = D_fontE;displayBuffer[1] = D_font1 ;

//当ad开路的时候，数码管显示 E1
#define F_displayPowerOff()  displayBuffer[4] = 0x00; displayBuffer[3] = D_fontBar ; displayBuffer[2] = D_fontBar ; \
                           displayBuffer[1] = D_fontBar
//当上电，没有按powner建时，显示   ---
#define F_displayAll()    displayBuffer[4] = 0xff;   displayBuffer[3] = 0xff; displayBuffer[2] = 0xff ; displayBuffer[1] = 0xff;

//没有数码管点的io口，所以无法点亮
//一上电的时候，自检显示 888
#define F_displayClrAll()   displayBuffer[3] = D_fontBlank ; displayBuffer[2] = D_fontBlank ; \
                           displayBuffer[1] = D_fontBlank
//全部数码管清空
//#define F_clrAllLed()		displayBuffer[0] = D_fontBlank
//led全部清零







#endif